package com.loby.config;

import com.loby.recordkey.argument.resolver.RecordKeyArgumentResolver;
import com.loby.service.api.AuthRecordServiceApi;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.RequestContextListener;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;

import java.util.List;

/**
 * 对权限访问接口进行初始化
 */
@Configuration
public class oAuth2Config extends org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport{
    @Reference(version = "1.0.0")
    AuthRecordServiceApi recordServiceApi;

//    @Bean
//    public RequestContextListener requestContextListener()
//    {
//        return new RequestContextListener();
//    }

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)
    {
        RecordKeyArgumentResolver recordKeyArgumentResolver = new RecordKeyArgumentResolver();
        recordKeyArgumentResolver.setAuthRecordServiceApi(recordServiceApi);
        argumentResolvers.add(recordKeyArgumentResolver);
    }
}
